package com.lightboat.system.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.deser.std.DateDeserializers;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.lightboat.common.annotation.Excel;
import com.lightboat.common.core.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.SchemaProperty;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 用户跟进记录对象 crm_user_follow_record
 * 
 * @author lightboat
 * @date 2025-08-22
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Schema(title = "用户跟进记录")
@TableName(value = "crm_user_follow_record", autoResultMap = true)
public class CrmUserFollowRecord extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    @SchemaProperty(name = "主键ID")
    @TableId
    private Long id;

    /** 用户ID */
    @SchemaProperty(name = "用户ID")
    @Excel(name = "用户ID")
    private Long userId;

    /** 用户名称 */
    @SchemaProperty(name = "用户名称")
    @TableField(exist = false)
    private String userName;

    /** 昵称 */
    @TableField(exist = false)
    @SchemaProperty(name = "昵称")
    private String nickName;

    /** 头像 */
    @TableField(exist = false)
    @SchemaProperty(name = "头像")
    private String avatar;



    /** 部门ID */
    @SchemaProperty(name = "部门编号")
    @TableField(fill = FieldFill.INSERT)
    @Excel(name = "部门编号", type = Excel.Type.IMPORT)
    private Long deptId;

    /** 类型CODE（用于区分角色） */
    @SchemaProperty(name = "类型CODE（用于区分角色）")
    @Excel(name = "类型CODE")
    @NotBlank
    private String typeCode;

    /** 客户ID */
    @SchemaProperty(name = "客户ID")
    @Excel(name = "客户ID")
    @NotNull
    private Long customerId;

    /** 订单ID */
    @SchemaProperty(name = "订单ID")
    @Excel(name = "订单ID")
    private Long orderId;

    /** 外部订单ID */
    @SchemaProperty(name = "外部订单ID")
    @Excel(name = "外部订单ID")
    private String externalOrderId;

    /** 跟进备注 */
    @SchemaProperty(name = "跟进备注")
    @Excel(name = "跟进备注")
    @NotBlank
    @TableField(condition = SqlCondition.LIKE)
    private String followRemark;

    /** 跟进时间 */
    @SchemaProperty(name = "跟进时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonDeserialize(using = DateDeserializers.DateDeserializer.class)
    @JsonSerialize(using = DateSerializer.class)
    @Excel(name = "跟进时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date followTime;

    /** 用量 */
    @SchemaProperty(name = "用量")
    @Excel(name = "用量")
    private BigDecimal  usageAmount;

    /** 用量结束时间 */
    @SchemaProperty(name = "用量结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = DateDeserializers.DateDeserializer.class)
    @JsonSerialize(using = DateSerializer.class)
    private Date usageEndTime;

    /** 用量更新时间 */
    @SchemaProperty(name = "用量更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = DateDeserializers.DateDeserializer.class)
    @JsonSerialize(using = DateSerializer.class)
    private Date usageUpdateTime;

    /** 置顶状态（0未置顶 1已置顶） */
    @SchemaProperty(name = "置顶状态（0未置顶 1已置顶）")
    @Excel(name = "置顶状态", readConverterExp = "0=未置顶,1=已置顶")
    private Integer topStatus;

    /** 是否跟进（0未跟进 1已跟进） */
    @SchemaProperty(name = "是否跟进（0未跟进 1已跟进）")
    @Excel(name = "是否跟进", readConverterExp = "0=未跟进,1=已跟进")
    private Integer isFollowed;

    /** 是否公开（0否 1是） */
    @SchemaProperty(name = "是否公开（0否 1是）")
    @Excel(name = "是否公开", readConverterExp = "0=否,1=是")
    private Integer isPrivate;

    /** 下次联系时间 */
    @SchemaProperty(name = "下次联系时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonDeserialize(using = DateDeserializers.DateDeserializer.class)
    @JsonSerialize(using = DateSerializer.class)
    @Excel(name = "下次联系时间", width = 30, dateFormat = "yyyy-MM-dd")
    @TableField(whereStrategy = FieldStrategy.NEVER)
    private Date contactNextTime;

    /** 是否自动置顶 0否 1是 */
    @SchemaProperty(name = "是否自动置顶 0否 1是")
    @Excel(name = "是否自动置顶 0否 1是")
    private Integer isAutoTop;

    /** 置顶排序 */
    @SchemaProperty(name = "置顶排序")
    @Excel(name = "置顶排序")
    private Long topSort;

    /** 置顶时间 */
    @SchemaProperty(name = "置顶时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = DateDeserializers.DateDeserializer.class)
    @JsonSerialize(using = DateSerializer.class)
    @Excel(name = "置顶时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date topTime;


    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("userId", getUserId())
            .append("customerId", getCustomerId())
            .append("orderId", getOrderId())
            .append("externalOrderId", getExternalOrderId())
            .append("followRemark", getFollowRemark())
            .append("followTime", getFollowTime())
            .append("usageAmount", getUsageAmount())
            .append("topStatus", getTopStatus())
            .append("isFollowed", getIsFollowed())
            .append("topSort", getTopSort())
            .append("topTime", getTopTime())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("remark", getRemark())
            .toString();
    }
}
